package com.example.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import com.example.demo.mapper.*;
import com.example.demo.pojo.Books;


@RestController
public class BooksController {
	@Autowired
	BooksMapper booksMapper;
	
	@GetMapping("deleteBooksByName/{name}")
	public int deleteBooksByName(@PathVariable String name) {
		System.out.println("已成功删除!");
		return booksMapper.deleteBooksByName(name);
}
		
	@GetMapping("findBooksById/{id}")
	public Books findBooksById(@PathVariable Integer id) {
			return booksMapper.findBooksById(id);
	}
	
	
	@GetMapping("insertBooks")
	public Books insertBooks(Books books) {		 
		 booksMapper.insertBooks(books);
		return books;
	}
	@GetMapping("updateBooks")
	public Books updateBooks(Books books) {		 
		 booksMapper.updateBooks(books);
		return books;
	}
	
	
    @GetMapping ("count")
    public int countBooks() {
    	return booksMapper.countBooks();
    }
    
	
}
